<?php 
//Xử lý xóa
if(isset($_POST['XOA']))
{
	$id=$_POST['id'];
	$sql="DELETE FROM tailieu WHERE id='$id'";
	mysql_query($sql);
	header("Location: index.php?option=tailieu");
}
if(isset($_POST['HUY']))
{
	header("Location: index.php?option=tailieu");
}
//Xử lý thêm tin
if(isset($_POST['DANG']))
{
	$name=$_POST['name'];
	
	$content=$_POST['content'];
	$images=$_FILES['images']['name'];
	$link=$_FILES['link']['name'];
	
	$states=$_POST['states'];
	$d=getdate();
    $time=gmdate("h:i:s", time()+7*3600);
    $datepost=$d['year']."-".$d['mon']."-".$d['mday']." ".$d['hours'].":".$d['minutes'].":".$d['seconds'];
	$sqlinsert="INSERT INTO tailieu(name,images,link,content,datepost,states)
	VALUES('$name','$images','$link','$content','$datepost','$states')";
	mysql_query("SET NAMES utf8");
	mysql_query($sqlinsert);
///upload hình
	move_uploaded_file($_FILES['images']['tmp_name'],"../../12/images/tailieu/".$images);
	move_uploaded_file($_FILES['link']['tmp_name'],"../../12/images/tailieu/".$link);
	header("Location: index.php?option=tailieu");
}
?>